
echo "==================================   Tool Download start   =================================="

mkdir -p /root/soft/
cd /root/soft/
		http://downloads.mysql.com/archives.php?p=mysql-5.0&v=5.0.67
wget -c http://downloads.mysql.com/archives/mysql-5.0/mysql-5.0.67.tar.gz
wget -c http://imcat.in/down/web/pcre/pcre-8.01.tar.gz
wget -c http://imcat.in/down/web/nginx/nginx-0.8.52.tar.gz
wget -c http://imcat.in/down/web/libiconv/libiconv-1.13.1.tar.gz
wget -c http://imcat.in/down/web/libmcrypt/libmcrypt-2.5.8.tar.gz
wget -c http://imcat.in/down/web/mhash/mhash-0.9.9.9.tar.gz
wget -c http://imcat.in/down/web/mcrypt/mcrypt-2.6.8.tar.gz
wget -c http://imcat.in/down/web/php/php-5.2.14.tar.gz
wget -c http://imcat.in/down/web/php-fpm/php-5.2.14-fpm-0.5.14.diff.gz
wget -c http://imcat.in/down/web/memcache/memcache-2.2.5.tgz
wget -c http://imcat.in/down/web/suhosin/suhosin-0.9.32.1.tar.gz
wget -c http://imcat.in/down/web/pdo_mysql/PDO_MYSQL-1.0.2.tgz
wget -c http://imcat.in/down/web/eaccelerator/eaccelerator-0.9.5.3.tar.bz2
wget -c http://catlnmp.googlecode.com/files/phpMyAdmin-3.3.6-all-languages.tar.gz

echo "==================================   Tool Download end   ===================================="

echo "==================================   安装MYSQL start         ===================================="

groupadd mysql
useradd -g mysql mysql
cd /root/soft/
tar -zxvf mysql-5.0.67.tar.gz
cd mysql-5.0.67/
./configure --prefix=/usr/local/mysql --with-berkeley-db
make
make install
cd ../
cp mysql-5.0.67/support-files/my-medium.cnf /etc/my.cnf
cp mysql-5.0.67/support-files/mysql.server /usr/local/mysql/bin
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R root /usr/local/mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql
chmod -R 777 /usr/local/mysql/bin/mysql.server
/usr/local/mysql/bin/mysql.server start
/usr/local/mysql/bin/mysqladmin -u root -p password 1


echo "==================================   安装MYSQL end           ===================================="

echo "==================================   安装PCRE start           ===================================="

cd /root/soft/
tar -zxvf pcre-8.01.tar.gz
cd pcre-8.01/
./configure
make
make install
cd ../

echo "==================================   安装PCRE end           ===================================="

echo "==================================   安装Nginx start           ===================================="

cd /root/soft/
tar -zxvf nginx-0.8.52.tar.gz
cd nginx-0.8.52/
./configure --prefix=/usr/local/nginx
make
make install
cd ../

echo "==================================   安装Nginx end           ===================================="

echo "==================================   编译安装PHP 5.2.14所需的支持库 start   ======================="

cd /root/soft/
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
cd ../

cd /root/soft/
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../

cd /root/soft/
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

cd /root/soft/
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../

echo "==================================   编译安装PHP 5.2.14所需的支持库 end    ======================"

echo "==================================   安装PHP start           ===================================="

cd /root/soft/
tar zxvf php-5.2.14.tar.gz
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
cd php-5.2.14/
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
make ZEND_EXTRA_LIBS='-liconv'
make install
cd ../
cp php-5.2.14/php.ini-dist /usr/local/php/etc/php.ini
sed -i '/<value name="user">nobody/c\<value name="user">nobody</value>' /usr/local/php/etc/php-fpm.conf
sed -i '/<value name="group">nobody/c\<value name="group">nobody</value>' /usr/local/php/etc/php-fpm.conf

echo "==================================   安装PHP end           ===================================="

echo "==================================   编译安装PHP5扩展模块 start           ===================================="

tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../

tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make
make install
cd ../

tar zxvf suhosin-0.9.32.1.tar.gz
cd suhosin-0.9.32.1/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../

tar jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3/
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config --with-eaccelerator-shared-memory
make
make install
cd ../

mkdir -p /usr/local/eaccelerator_cache
cat >>/usr/local/php/etc/php.ini<<EOF
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
EOF

sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\nextension = "suhosin.so"\n#' /usr/local/php/etc/php.ini
sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/php/etc/php.ini
sed -i 's/; cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/g' /usr/local/php/etc/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 16M/g' /usr/local/php/etc/php.ini
sed -i 's/;date.timezone =/date.timezone = PRC/g' /usr/local/php/etc/php.ini

echo "==================================   编译安装PHP5扩展模块 end           ===================================="